<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function sub(){
				var n1=document.getElementById("n1").value
				var n2=document.getElementById("n2").value
				var n3=n1-n2
				//document.getElementById("n3").value=n3
				document.getElementById("n3").setAttribute("value",n3)
			}
			function add(){
				var n1=document.getElementById("n1").value
				var n2=document.getElementById("n2").value
				//var n3=Number(n1)+Number(n2)
				var n3=n1/1+n2*1
				// var n3=(n1-0)+(n2-0)
				n3=n3.toFixed(15)-0
				//document.getElementById("n3").value=n3
				document.getElementById("n3").setAttribute("value",n3)
			}
			function mul(){
				var n1=document.getElementById("n1").value
				var n2=document.getElementById("n2").value
				var n3=n1*n2
				n3=n3.toFixed(15)-0
				//document.getElementById("n3").value=n3
				document.getElementById("n3").setAttribute("value",n3)
			}
			function div(){
				var n1=document.getElementById("n1").value
				var n2=document.getElementById("n2").value
				if(isNaN(n1)||isNaN(n2)){
				document.getElementById("n3").value="只能输入数字进行运算"
				return;
				}
				var n3=n1/n2
				//document.getElementById("n3").value=n3
				if (!isFinite(n1)){document.getElementById("n3").setAttribute("value","除数不能为0")
				return;}
				document.getElementById("n3").setAttribute("value",n3)
			}
		</script>
	</head>
	<body>
		第一个数：<input type="text" id="n1" /><br>
		第二个数：<input type="text" id="n2" /><br>
		<button onclick="add()">+</button>
		<button onclick="sub()">-</button>
		<button onclick="mul()">*</button>
		<button onclick="div()">/</button><br>
		第三个数：<input type="text" id="n3" /><br>
	</body>
</html>
